<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{% block title %}图书管理系统{% endblock %}</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
    <style>
        body,html {
            width: 100%;
            top: 100%;
            margin: 0;
            padding: 0;
            font-size: 16px;
        }
        .base-nav, .base-ul, .base-li {
            margin-top: 1rem;
            margin-bottom: 1rem;
            width: 100%;
            border: none!important;
            text-align: center;
            font-size: 2rem;
            cursor: pointer;
        }
        a {text-decoration: none;}
        .base-li {
            border-bottom: 1px solid black!important;
            margin-right: 0.5rem;
        }
        {% block style %}
        {% endblock %}
    </style>
</head>
<body>
<header>
    <nav class="base-nav">
        <ul class="list-group list-group-horizontal base-ul">
            
            <!-- <li class="list-group-item base-li"><a href="{{ url_for('book_manage.book_list') }}">书籍列表</a></li> -->
            
            {% if current_user.is_authenticated %}
                {% if is_common_user() %}
                    <li class="list-group-item base-li"><a href="{{ url_for('user_card.card_view') }}">我的借阅证</a></li>
                    <li class="list-group-item base-li"><a href="{{ url_for('user_borrow.borrow_list') }}">我借阅的书籍</a></li>
                    <li class="list-group-item base-li"><a href="{{ url_for('user_borrow.book_list') }}">书籍浏览</a></li>
                {% elif is_sys_admin() %}
                    <li class="list-group-item base-li"><a href="{{ url_for('card_manage.card_apply_list') }}">借阅证管理</a></li>
                    <li class="list-group-item base-li"><a href="{{ url_for('book_manage.book_list') }}">书籍管理</a></li>
                    <li class="list-group-item base-li"><a href="{{ url_for('borrow_manage.borrow_list') }}">借阅管理</a></li>
                    <li class="list-group-item base-li"><a href="{{ url_for('user_manage.user_list') }}">用户管理</a></li>
                {% else %}
                    <li class="list-group-item base-li"><a href="{{ url_for('card_manage.card_apply_list') }}">借阅证管理</a></li>
                    <li class="list-group-item base-li"><a href="{{ url_for('book_manage.book_list') }}">书籍管理</a></li>
                    <li class="list-group-item base-li"><a href="{{ url_for('borrow_manage.borrow_list') }}">借阅管理</a></li>
                {% endif %}
                <li class="list-group-item base-li"><a href="{{ url_for('auth.logout') }}">登出</a></li>
            {% else %}
            <li class="list-group-item base-li"><a href="{{ url_for('auth.login') }}">登录</a></li>
            <li class="list-group-item base-li"><a href="{{ url_for('auth.register') }}">注册</a></li>
            {% endif %}
        </ul>
    </nav>
</header>

<main>
    <!-- Flash消息 -->
    {% with messages = get_flashed_messages(with_categories=true) %}
      {% if messages %}
        <ul>
        {% for category, message in messages %}
          
            {% if category == 'action' and message == 'need_payment' %}
            <li class="alert-action">
                {% if borrow_book and pay_form %}
                <form method="POST" action="{{ url_for('user_return.post_pay') }}">
                    {{ pay_form.hidden_tag() }}
                    <p>
                        <input type="hidden" name="borrow_book_id" value="{{ borrow_book.id }}">
                        <p>
                            {{ pay_form.overdue_fee.label }}<br>
                            <input type="text" id="overdue_fee" name="overdue_fee" value="{{ borrow_book.overdue_fee }}" readonly>
                            {% for error in pay_form.overdue_fee.errors %}
                                <span style="color: red;">[{{ error }}]</span>
                            {% endfor %}
                        </p>
                        {% for error in pay_form.borrow_book_id.errors %}
                            <span style="color: red;">[{{ error }}]</span>
                        {% endfor %}
                    </p>
                    <p>{{ pay_form.submit() }}</p>
                </form>
                {% endif %}
            </li>
            {% else %}
            <li class="alert-{{ category }}">{{ message }}</li>
            {% endif %}
        {% endfor %}
        </ul>
      {% endif %}
    {% endwith %}
    {% block content %}
    {% endblock %}
</main>

<footer>
    <p>&copy; 2025 图书管理系统</p>
</footer>
</body>
</html>